<?php
/**
 * Created by PhpStorm.
 * User: ytl003
 * Date: 2018/10/1
 * Time: 下午8:04
 */

namespace app\api\controller;


use app\api\model\BannerModel;
use app\api\service\Back;
use app\api\validate\WhereValidate;

class Banner
{
    /**
     * @route('banner/:location')
     * @param $location
     * @param int $size
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \app\lib\exception\ParameterException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function get($location,$size=5){
        (new WhereValidate())->goCheck();
        $banner =  BannerModel::where('location',$location)->order('order')->limit($size)->select();
        return Back::success($banner);
    }
}